Matrix Multiplication
Introduction
Matrix multiplication is a way to combine two transformations into a single transformation.
If you already know how a matrix acts on a vector—turning $v$ into $Av$—then matrix multiplication tells you how to apply two such actions in a row using one new matrix.
This idea is powerful because it lets us:
- Chain multiple transformations together
- Simplify repeated operations
- Understand how geometry changes under sequences of moves
Why Combine Transformations?
Some common reasons:
- Applying a rotation then a scaling
- Applying a shear then a reflection
- Applying a camera transform then a projection (in graphics)
- Applying a coordinate change then a measurement
Instead of computing each step separately, we can build one matrix that does everything at once.
Matrix Multiplication as “Do This, Then That”
Suppose:
- $A$ is a matrix that transforms vectors first
- $B$ is a matrix that transforms vectors second
If you apply $A$ then $B$ to a vector $v$, you compute: $$B(Av)$$ Matrix multiplication defines a new matrix $C$ such that: $$C v = B(Av)$$ So the combined matrix is: $$C = BA$$ Important:
The order is right-to-left because the vector is on the right.
How Matrix Multiplication Works
To multiply two matrices:
- Take each row of the left matrix
- Take each column of the right matrix
- Multiply matching entries
- Add the results
For example, if $$A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}, \quad B = \begin{pmatrix} p & q \\ r & s \end{pmatrix}$$ Then: $$BA = \begin{pmatrix} pa + qc & pb + qd \\ ra + sc & rb + sd \end{pmatrix}$$ You don’t need to memorize this—just remember:
- Rows of the first matrix
- Columns of the second matrix
- Multiply + add
Geometric Meaning
Matrix multiplication corresponds to doing one geometric action after another.
Examples:
- Rotate then scale
- Shear then rotate
- Reflect then shear
Each combined action is still linear, so it can be represented by a single matrix.
Common Mistakes
- Order matters.
In general, $AB \neq BA$. - You can only multiply if the inner dimensions match.
If $A$ is $m \times n$ and $B$ is $n \times p$, then $BA$ is defined. - Matrix multiplication is not element‑wise.
It’s row–column multiplication.
Calculator
Multiplying matrices
- Matrices can be multiplied in the same way as any other data type:
[1, 2; 0, 1] * [3, 0; 1, 4] multiply([1, 0; 0, 1], [3, -2; 1, 1])
Exercises
- Multiply the matrices $$\begin{pmatrix}1 & 2 \\ 0 & 1\end{pmatrix} \begin{pmatrix}3 & 0 \\ 1 & 4\end{pmatrix}$$
- Compute the product $$\begin{pmatrix}2 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}4 \\ 3\end{pmatrix}$$
- Let $A$ be a rotation matrix and $B$ be a scaling matrix.
Explain in words what the matrix $BA$ represents. - Determine whether the product $AB$ is defined if
$A$ is $2 \times 3$ and $B$ is $3 \times 2$. - tranform the vector by the matrix $$\begin{pmatrix}0 & 1 \\ 1 & 0\end{pmatrix} \begin{pmatrix}5 \\ 7\end{pmatrix}$$
- True or false: If $AB$ is defined, then $BA$ is always defined.
- Compute $$\begin{pmatrix}3 & -1 \\ 2 & 4\end{pmatrix} \begin{pmatrix}1 & 0 \\ 0 & 2\end{pmatrix}$$